package com.nncsys.dataset

import org.apache.flink.api.scala.ExecutionEnvironment
import org.apache.flink.api.scala._
/**
 * Created with IntelliJ IDEA
 * <p>说明：</p>
 *
 * @author micheal
 * @see
 * @since 2020/04/01 0001 14:46
 */
object DataSetWcDemo {

  def main(args: Array[String]): Unit = {

    val env: ExecutionEnvironment = ExecutionEnvironment.getExecutionEnvironment

    val lines: DataSet[String] = env.readTextFile("D:/FileSystem/data.txt")
    val result: AggregateDataSet[(String, Int)] = lines
      .flatMap(_.split(" "))
      .filter(_.nonEmpty)
      .map((_, 1))
      .groupBy(0)
      .sum(1)

    result.print()

  }

}
